<!DOCTYPE html>
<html>
	<head>
		{include file="public/_header" /}
	</head>
	<body style="background: #fff;padding-left: 20px;">
		<form class="layui-form" action="">
			<input type="hidden" name="id" value="{$id}">
			<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
				<ul class="layui-tab-title">
					<li class="layui-this">基本选项</li>
					<!-- <li>高级设置</li> -->
					<!-- <li>权限分配</li> -->
				</ul>
				<div class="layui-tab-content">
					<div class="layui-tab-item layui-show">

						<div class="layui-form-item">
							<label class="layui-form-label">所属栏目</label>
							<div class="layui-input-inline" style="min-width: 400px;">
								<select name="pid" lay-verify="required">
									<option value="0">顶级栏目</option>
									{volist name="cate" id="item"}
									<option value="{$item.pid}" {if($item.pid == $curarr.pid) }selected{/if}>{$item._name} </option> {/volist} </select> </div>
									 </div> <div class="layui-form-item">
										<label class="layui-form-label">栏目名称</label>
										<div class="layui-input-inline" style="min-width: 400px;">
											<input type="text" value="{$curarr.name}" name="name" required lay-verify="required" placeholder="请输入栏目名称" autocomplete="off" class="layui-input">
										</div>
										<div class="layui-form-mid layui-word-aux">栏目名称</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">内容模型</label>
								<div class="layui-input-inline" style="min-width: 400px;">
									<select name="model_id" lay-verify="required" lay-filter="model">
										{volist name="mlist" id="item"}
											<option value="{$item.id}" {if($item.id == $model_id)} selected {/if}>{$item.name}</option>
										{/volist}

									</select>
								</div>
								<div class="layui-form-mid layui-word-aux">请设置页面模板</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">别名(拼音)</label>
								<div class="layui-input-inline" style="min-width: 400px;">
									<input type="text" value="{$curarr.ename}" name="ename" placeholder="" autocomplete="off" class="layui-input">
								</div>
								<div class="layui-form-mid layui-word-aux">辅助文字</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">是否显示</label>
								<div class="layui-input-block" style="min-width: 400px;">
									<input type="checkbox" name="status" value="1" lay-skin="switch" lay-text="ON|OFF" checked>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">栏目模板</label>
								<div class="layui-input-inline" style="min-width: 400px;">
									<select name="template_list" lay-verify="required" lay-filter="temp_list">
										{volist name="temp_list" id="item"}
										<option value="{$item}" {if($curarr.template_list == $item)}selected{/if}>{$item} </option>
										{/volist}
									</select> </div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">内容页模板</label>
								<div class="layui-input-inline" style="min-width: 400px;">
									<select name="template_show" lay-verify="required">
										{volist name="temp_show" id="item"}
										<option value="{$item}" {if($curarr.template_show == $item)}selected{/if}>{$item} </option> {/volist}
									</select> </div>
							</div>
							<div class="layui-form-item layui-form-text">
								<label class="layui-form-label">栏目描述</label>
								<div class="layui-input-block">
									<textarea name="description" placeholder="请输入内容" class="layui-textarea">{$curarr.description}</textarea>
								</div>
							</div>
						</div>
						<div class="layui-tab-item">
							
						</div>
						<!-- <div class="layui-tab-item">内容3</div> -->
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
						</div>
					</div>
				</div>
		</form>
	</body>
</html>
<script>
	//Demo
	layui.use('form', function() {
		var form = layui.form;

		//监听提交
		form.on('submit(formDemo)', function(data) {
			
			$.ajax({
				type: "post",
				url: "{:url('admin/category/edit_add')}",
				data: data.field,
				dataType: "json",
				success: function(res) {
					console.log(res.data)
					if(res.data){
						layer.msg('编辑成功', {
						  icon: 1,
						  time: 500 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
							parent.layer.close(index);
							reloadMain()
						});  
						
					}
				},
			});
			return false;
		});
		form.on('select(model)', function(data){
			$.ajax({
				type: "post",
				url: "{:url('admin/category/get_temp')}",
				data: {
					model_id:data.value
				},
				dataType: "json",
				success: function(res) {
					$("select[name='template_list']").val(res.data.template_list);
					$("select[name='template_show']").val(res.data.template_show);
					layui.form.render("select");
				},
			});

		})
	});
</script>
